package org.yourscrum.web;

privileged aspect TaskController_Roo_Controller {
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/task", method = org.springframework.web.bind.annotation.RequestMethod.POST)    
    public java.lang.String TaskController.create(@org.springframework.web.bind.annotation.ModelAttribute("task") org.yourscrum.domain.Task task, org.springframework.validation.BindingResult result) {    
        if (task == null) throw new IllegalArgumentException("A task is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Task> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(task)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "task/create";            
        }        
        task.persist();        
        return "redirect:/task/" + task.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/task/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TaskController.createForm(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("task", new org.yourscrum.domain.Task());        
        modelMap.addAttribute("comments", org.yourscrum.domain.Comment.findAllComments());        
        modelMap.addAttribute("stories", org.yourscrum.domain.Story.findAllStories());
        return "task/create";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/task/{id}", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TaskController.show(@org.springframework.web.bind.annotation.PathVariable("id") Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("task", org.yourscrum.domain.Task.findTask(id));        
        return "task/show";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/task", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TaskController.list(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("tasks", org.yourscrum.domain.Task.findAllTasks());        
        return "task/list";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(method = org.springframework.web.bind.annotation.RequestMethod.PUT)    
    public java.lang.String TaskController.update(@org.springframework.web.bind.annotation.ModelAttribute("task") org.yourscrum.domain.Task task, org.springframework.validation.BindingResult result) {    
        if (task == null) throw new IllegalArgumentException("A task is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Task> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(task)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "task/update";            
        }        
        task.merge();        
        return "redirect:/task/" + task.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/task/{id}/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String TaskController.updateForm(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("task", org.yourscrum.domain.Task.findTask(id));        
        modelMap.addAttribute("comments", org.yourscrum.domain.Comment.findAllComments());        
        modelMap.addAttribute("stories", org.yourscrum.domain.Story.findAllStories());        
        return "task/update";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/task/{id}", method = org.springframework.web.bind.annotation.RequestMethod.DELETE)    
    public java.lang.String TaskController.delete(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        org.yourscrum.domain.Task.findTask(id).remove();        
        return "redirect:/task";        
    }    
    
}
